package com.test.java;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeZone {

    static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    static DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");

    public static void main(String[] args) {

        LocalDateTime now = LocalDateTime.now();

        System.out.println("now: " + dateFormatter.format(now));

        ZonedDateTime zoneNow = now.atZone(ZoneId.of("-01:00"));

        System.out.println("zoneNow: " + dateFormatter.format(zoneNow));

        ZonedDateTime covered = zoneNow.withZoneSameInstant(ZoneId.of("+08:00"));

        System.out.println("covered: " + dateFormatter.format(covered));


        LocalTime nowTime = now.toLocalTime();

        OffsetTime nowZoneTime = nowTime.atOffset(ZoneOffset.of("-01:00"));

        System.out.println(timeFormatter.format(nowZoneTime));

        OffsetTime coveredTime = nowZoneTime.withOffsetSameInstant(ZoneOffset.of("+08:00"));

        System.out.println(timeFormatter.format(coveredTime));

    }



}
